/**
 * TO BE DETERMINED
 */
package org.eichar.client.observer;

import org.eichar.client.Question;

import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.Widget;

/**
 * Asks the question if it has been answered correctly. If yes then the next
 * button is highlighted and the try again button is disabled. A message is also
 * displayed indicating to the user that the answer was correct or incorrect.
 * 
 * @author Jesse
 */
public class AcceptObserver implements ClickListener {

    private final Question question;

    private final Button next;

    /**
     * New instance
     */
    public AcceptObserver(Button accept, Question question, Button next) {
        accept.addClickListener(this);
        this.question = question;
        this.next = next;
    }

    /**
     * @see com.google.gwt.user.client.ui.ClickListener#onClick(com.google.gwt.user.client.ui.Widget)
     */
    public void onClick(Widget sender) {
        if (question.isCorrect()) {
            next.setFocus(true);
        } else {
            question.setFocus(true);
        }
        // TODO Auto-generated method stub

    }

}
